package cn.mazexal.exambg.common.models;

import java.util.List;

/**
 * @author: Mazexal
 * Date: 2025/5/11
 */

public class PagedData<T> extends DTO {
    private static final long serialVersionUID = 1L;
    private int current;
    private int total;
    private int pageSize;
    private List<T> data;

    public int getCurrent() {
        return this.current;
    }

    public void setCurrent(int current) {
        this.current = current;
    }

    public int getTotal() {
        return this.total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public List<T> getData() {
        return this.data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public static <T> PagedData<T> of(PagedQry qry, long total, List<T> list) {
        return of(qry, (int)total, list);
    }

    public static <T> PagedData<T> of(PagedQry qry, int total, List<T> list) {
        PagedData<T> pagedData = new PagedData();
        pagedData.setCurrent(qry.getCurrent());
        pagedData.setPageSize(qry.getPageSize());
        pagedData.setTotal(total);
        pagedData.setData(list);
        return pagedData;
    }
}
